<template>
    <div>
        <Form
                ref="form"
                :form-items="formItems"
        ></Form>
       <MassDoSend :form-data="formData"></MassDoSend>
    </div>

</template>

<script>
    import Form from '../../../../../common-util/src/components/page/Form.vue'
    import MassDoSend from './MassDoSend.vue'
    export default {
        components:{
            Form,
            MassDoSend
        },
        data(){
            return {
                formItems:[
                    {
                        field: {
                            name: 'appCode'
                        },
                        element:{
                            type: 'select',
                            select:{
                                url: this.$baseURL.wx + '/wx/mp/config/list',
                                optionProp:{
                                    value: 'appCode',
                                    label: 'appName'
                                }
                            },
                            required: true,
                            label: '公众号',
                        }
                    },
                    {
                        field: {
                            name: 'msgType'
                        },
                        element:{
                            type: 'selectLocal',
                            selectLocal: {
                                data: [
                                    {
                                        id: 'text',
                                        name: '文本'
                                    },
                                    {
                                        id: 'image',
                                        name: '图片'
                                    },
                                    {
                                        id: '声音',
                                        name: 'voice'
                                    },
                                ]
                            },
                            required: true,
                            label: '消息类型',
                        }
                    },
                    {
                        field: {
                            name: 'content'
                        },
                        element:{
                            type: 'textarea',
                            label: '内容',
                            placeholder: '发送的文本内容',
                            required: true,
                            show: (form)=>{ return form.msgType == 'text'}
                        }
                    },
                    {
                        field: {
                            name: 'mediaId'
                        },
                        element:{
                            label: '媒体id',
                            placeholder: '需要在素材管理中获取,永久素材媒体id',
                            required: true,
                            show: (form)=>{ return form.msgType != 'text'}
                        }
                    }
                ],
            }
        },
        methods:{
            formData(){
                let r = false
                this.$refs.form.validateAndSubmitForm(()=>{
                    r = true
                })
                if(r == false){
                    return false
                }
                return this.$refs.form.getFormData()
            }
        }
    }
</script>

<style scoped>

</style>